function Phb()
{
	this.init();
	//this.baseUrl = "http://112.124.121.34:8201/lion_module_share_temp";
	this.baseUrl = "http://event.m.shihou.tv/lion_module_share_temp";
}
Phb.prototype={
	init:function()
	{
		var _this = this;
		_this.changePhb($("#phb"));	
		_this.changePhb2($(".phb_1"));
		_this.tab();
		_this.length();	
		_this.tongjiAjax();
	},
	tongjiAjax:function(){
		var _this = this;
		$(".downlogo").bind("touchend", function(){
			_this.tongji();	
		});
	},
	//活动详情和排行tab
	changePhb:function(obj)
	{
		var iTab  = obj.find(".menu li");
		var iCont = obj.find(".phb");
		iCont.eq(1).show();
		iTab.bind("touchend",function()
		{
			var currIndex = $(this).index();
			iTab.eq(currIndex).addClass("curr").siblings().removeClass("curr");
			iCont.eq(currIndex).show().siblings().hide();
		});
	},
	//小蜜蜂奖、万人迷奖、魅力偶像奖、神豪奖tab
	changePhb2:function(obj)
	{
		var _this = this;
		var iTab  = obj.find(".Text");
		iTab.bind("touchend",function()
		{
			var currIndex = $(this).index();
			iTab.eq(currIndex).addClass("curr").siblings().removeClass("curr");
			//add by lichenyi
			$("#type").val(currIndex+1);
			_this.shihouStars1();
		});
	},
	length:function()
	{
		var d = new Date();
		var str = getDate((d.getMonth()+1))+""+getDate(d.getDate());
		var dates = new Array();
		dates[0] = ['0109', '0110', '0111', '0112', '0113', '0114', '0115'];
		dates[1] = ['0116', '0117', '0118', '0119', '0120', '0121', '0122'];
		dates[2] = ['0123', '0124', '0125', '0126', '0127', '0128', '0129'];
		dates[3] = ['0130', '0131', '0201', '0202', '0203', '0204', '0205'];
		dates[4] = ['0206', '0207', '0208', '0209', '0210', '0211', '0212'];
		var dateLichenyi = new Array();
			dateLichenyi[0] = ['2017-01-09', '2017-01-15'];
			dateLichenyi[1] = ['2017-01-16', '2017-01-22'];
			dateLichenyi[2] = ['2017-01-23', '2017-01-29'];
			dateLichenyi[3] = ['2017-01-30', '2017-02-05'];
			dateLichenyi[4] = ['2017-02-06', '2017-02-12'];
		function getDate(val){
			if(val < 10)
				return "0"+val;
			return val;
		}
		function getWeek(){ 
			var sign = 0;
			for (x in dates){
				if(dates[x].indexOf(str) > -1){
					//sign = parseInt(x)+1;
					sign = parseInt(x);
					$('#startDate').val(dateLichenyi[x][0]);
					$('#endDate').val(dateLichenyi[x][1]);
				}
			}
			if(sign > 0){
				$('.zhoubang img').css("display", "block");
			}
			for(var i=0;i<sign;i++)
			{
				$(".weekFour li").eq(i).show();
				if(i+1 == sign){
					$(".weekFour li").eq(i).after('<li class="curr"><em></em>本周<em></em></li>');// add by lichenyi 
					$(".weekFour li").eq(i+1).show();
				}
			}
		}
		getWeek();	
	},
	//周榜和总榜和四周的tab
	tab:function(obj)
	{
		var _this = this;
		$(".box2").eq(0).show();
		$(".zhoubang_1 li").live("touchend",function()
		{
			$(".weekFour").hide();
			var currIndex = $(this).index();
			$(".RankingList li").eq(currIndex).addClass("curr").siblings().removeClass("curr");
			$(".box2").eq(currIndex).show().siblings().hide();
			
			//add by lichenyi 周榜第一次加载
			var dateLichenyi = new Array();
			dateLichenyi[0] = 'week';
			dateLichenyi[1] = 'zong';
			var zongWeek = $('#zongWeek').val();
			$('#zongWeek').val(dateLichenyi[currIndex]);
			if(!(zongWeek == "week" && dateLichenyi[currIndex] == "week")){
				_this.shihouStars1(); //第一次加载	
			}
		});
		var Onclick = false;
		$(".zhoubang_1 .curr").live("touchend",function()
		{
			if($(this).hasClass("zhoubang")&&!Onclick)
			{
				$(".weekFour").show();
				Onclick = true;
			}else{
				$(".weekFour").hide();
				Onclick = false;
			}
		});
		$(".weekFour li").live("touchend",function()
		{
			if($(this).hasClass("zhoubang")&&!Onclick)
			{
				$(".weekFour").show();
				Onclick = true;
			}else{
				$(".weekFour").hide();
				Onclick = false;
			}
			
			var Index = $(this).index();
			$(".weekFour").hide();
			$(".weekFour li").eq(Index).addClass("curr").siblings().removeClass("curr");
			$(".zhoubang_1 .curr p").html($(".weekFour li").eq(Index).html());
			
			//add by lichenyi   点击周 第一次加载
			$('#week').val(Index+1);
			var dateLichenyi = new Array();
			dateLichenyi[0] = ['2017-01-09', '2017-01-15'];
			dateLichenyi[1] = ['2017-01-16', '2017-01-22'];
			dateLichenyi[2] = ['2017-01-23', '2017-01-29'];
			dateLichenyi[3] = ['2017-01-30', '2017-02-05'];
			dateLichenyi[4] = ['2017-02-06', '2017-02-12'];
			var type = $('#type').val();
			if(type == '1'){
				$('#startDate').val(dateLichenyi[Index][0].split('-').join(''));
				$('#endDate').val(dateLichenyi[Index][1].split('-').join(''));
				_this.xiaomifeng1($('#startDate').val().split("-").join(""), $('#endDate').val().split("-").join(""), 0, 10);
			}
			$('#startDate').val(dateLichenyi[Index][0]);
			$('#endDate').val(dateLichenyi[Index][1]);
			if(type == '2'){
				_this.wanrenmi1($('#startDate').val(), $('#endDate').val(), 0, 10);
			}
			if(type == '3'){
				_this.meiliouxiang1($('#startDate').val(), $('#endDate').val(), 0, 10);
			}
			if(type == '4'){
				_this.shenhao1($('#startDate').val(), $('#endDate').val(), 0, 10);
			}
		});
	},
	shihouStars1:function(){//数据第一次加载
		var _this = this;
		var type = $('#type').val();
		var zongWeek = $('#zongWeek').val();
		
		//每次加载之前都将列表清空
		_this.clearList();
		
		var titleArray = new Array();
		titleArray = ['xiaomifengbaoming', 'wanrenmiTitle', 'wmeiliouxiangTitle', 'shenhaoTitle'];
		$('#'+titleArray[parseInt(type-1)]).css("display", "block").siblings().css("display", "none");
		
		if(zongWeek == "week"){
			if(type == '1'){
				_this.xiaomifeng1($('#startDate').val().split("-").join(""), $('#endDate').val().split("-").join(""), 0, 10);	
			}	
			if(type == '2'){
				_this.wanrenmi1($('#startDate').val(), $('#endDate').val(), 0, 10);
			}	
			if(type == '3'){
				_this.meiliouxiang1($('#startDate').val(), $('#endDate').val(), 0, 10);
			}	
			if(type == '4'){
				_this.shenhao1($('#startDate').val(), $('#endDate').val(), 0, 10);
			}	
		}else{
			if(type == '1'){
				$('#xiaomifengbaoming').show();
				_this.xiaomifeng1('', '', 0, 10);	
			}	
			if(type == '2'){
				_this.wanrenmi1('', '', 0, 10);
			}	
			if(type == '3'){
				_this.meiliouxiang1('', '', 0, 10);
			}	
			if(type == '4'){
				_this.shenhao1('', '', 0, 10);
			}	
		}
	},
	shihouStars2:function(){//数据第二次加载  点击加载更多
		var _this = this;
		var type = $('#type').val();
		var zongWeek = $('#zongWeek').val();
		$('#xiaomifengbaoming').hide();
		
		if(zongWeek == "week"){
			if(type == '1'){
				$('#xiaomifengbaoming').show();
				_this.xiaomifeng2($('#startDate').val().split("-").join(""), $('#endDate').val().split("-").join(""), 10, 20);	
			}	
			if(type == '2'){
				_this.wanrenmi2($('#startDate').val(), $('#endDate').val(), 10, 20);
			}	
			if(type == '3'){
				_this.meiliouxiang2($('#startDate').val(), $('#endDate').val(), 10, 20);
			}	
			if(type == '4'){
				_this.shenhao2($('#startDate').val(), $('#endDate').val(), 10, 20);
			}	
		}else{
			if(type == '1'){
				$('#xiaomifengbaoming').show();
				_this.xiaomifeng2('', '', 10, 20);	
			}	
			if(type == '2'){
				_this.wanrenmi2('', '', 10, 20);
			}	
			if(type == '3'){
				_this.meiliouxiang2('', '', 10, 20);
			}	
			if(type == '4'){
				_this.shenhao2('', '', 10, 20);
			}	
		}
	},
	xiaomifeng1:function(startDate, endDate, startOffset, pageSize){
		var _this = this;
        _this.requestRemoteData({'url': encodeURI(encodeURI(location.href.split('#')[0])), "type":"1", "startTime":startDate, "endTime":endDate, "startOffset":startOffset, "pageSize":pageSize, "userId":$('#userId').val(), "configId":$('#configId').val()}, function(res){
        	var user = res.user;
        	if(res.errorCode != 0){
        		return;
        	}
        	var total = res.result.length;
        	var html = '';
        	var html1 = '';
        	var html2 = '';
        	var html3 = '';
        	
        	var data1 = res.result[0];
        	var data2 = res.result[1];
        	var data3 = res.result[2];
        	
			if(total > 0 && typeof(data1.user) != "undefined"){
				html1 += '<li class="phbNo1">';
			    html1 += '    <a href="javascript:void(0)">';
                html1 += '    <section class="phbHead">';
                html1 += '        <div class="phbWrap">';
                   	/*if(data1.user.roomInfo != null && data1.user.roomInfo.vdo_status == '1'){
			    		html1 += '            <span></span>';
					    html1 += '            <div class="loader-inner line-scale-pulse-out">';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '            </div>';
			    	}*/
                html1 += '            <img src="'+data1.user.avatar+'" />';
                html1 += '        </div>';
                html1 += '    </section>';
                html1 += '    <h3 class="phbName">'+ data1.user.nick_name +'</h3>';
                html1 += '    <span class="phbTime">时长：'+data1.totalEffectTimeStr+'</span>';
                html1 += '    <em class="iconNo1"></em>';
                html1 += '	</a>';
                html1 += '</li>';
			}
			if(total > 1 && typeof(data2.user) != "undefined"){
				html2 += '<li class="phbNo2">';
			    html2 += '    <a href="javascript:void(0)" class="phbHead">';
			    html2 += '       <div class="phbWrap">';
			    	/*if(data2.user.roomInfo != null && data2.user.roomInfo.vdo_status == '1'){
			    		html2 += '<span></span>';
		                html2 += '<div class="loader-inner line-scale-pulse-out">';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '</div>';
			    	}*/
			    html2 += '            <img src="'+data2.user.avatar+'" />';
			    html2 += '        </div>';
			    html2 += '    </a>';
			    html2 += '    <h3 class="phbName">'+ data2.user.nick_name +'</h3>';
			    html2 += '    <span class="phbTime">时长：'+ data2.totalEffectTimeStr +'</span>';
			    html2 += '    <em class="iconNo2"></em>';
			    html2 += '</li>';
			}
			if(total > 2 && typeof(data3.user) != "undefined"){
				html3 += '<li class="phbNo3">';
			    html3 += '    <a href="javascript:void(0)" class="phbHead">';
			    html3 += '       <div class="phbWrap">';
			    	/*if(data3.user.roomInfo != null && data3.user.roomInfo.vdo_status == '1'){
			    		html3 += '<span></span>';
		                html3 += '<div class="loader-inner line-scale-pulse-out">';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '</div>';
			    	}*/
			    html3 += '            <img src="'+data3.user.avatar+'" />';
			    html3 += '        </div>';
			    html3 += '    </a>';
			    html3 += '    <h3 class="phbName">'+ data3.user.nick_name +'</h3>';
			    html3 += '    <span class="phbTime">时长：'+ data3.totalEffectTimeStr +'</span>';
			    html3 += '    <em class="iconNo3"></em>';
			    html3 += '</li>';
			}
			
			for (var i = 0; i < total; i++) {
				var data = res.result[i];
				if(typeof(data.user)=="undefined" || i < 3){
					continue;
				}
				html += '<li>';
			    html += '    <a href="javascript:void(0)" class="phbHead">';
			    html += '        <div class="phbWrap">';
			    	/*if(data.user.roomInfo != null && data.user.roomInfo.vdo_status == '1'){
			    		html += '            <span></span>';
					    html += '            <div class="loader-inner line-scale-pulse-out">';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '            </div>';
			    	}*/
			    html += '            <img src="'+data.user.avatar+'" />';
			    html += '        </div>';
			    html += '    </a>';
			    html += '    <h3 class="phbName">'+ data.user.nick_name +'</h3>';
			    html += '    <span class="phbTime">时长：'+ data.totalEffectTimeStr +'</span>';
			    html += '    <em class="phbCount">'+(i+1)+'</em>';
			    html += '</li>';
			}
			var zongWeek = $('#zongWeek').val();
			if(zongWeek == 'week'){
				//前三条显示
				$("#weekPhbTopThree").find("ul").html(html2+html1+html3);
				//余下的显示
				$("#weekphbList").html(html);
				$("#weekphbList").append('<a class="more">点击查看更多</a>');
			}else if(zongWeek == 'zong'){
				//前三条显示
				$("#zongPhbTopThree").find("ul").html(html2+html1+html3);
				//余下的显示
				$("#zongphbList").html(html);
				$("#zongphbList").append('<a class="more">点击查看更多</a>');
			}
        });
	},
	xiaomifeng2:function(startDate, endDate, startOffset, pageSize){
		var _this = this;
        _this.requestRemoteData({'url': encodeURI(encodeURI(location.href.split('#')[0])), "type":"1", "startTime":startDate, "endTime":endDate, "startOffset":startOffset, "pageSize":pageSize, "userId":$('#userId').val(), "configId":$('#configId').val()}, function(res){
        		var total = res.result.length;
            	var html = '';
				for (var i = 0; i < total; i++) {
					var data = res.result[i];
					if(typeof(data.user)=="undefined"){
						continue;
					}
					html += '<li>';
				    html += '    <a href="javascript:void(0)" class="phbHead">';
				    html += '        <div class="phbWrap">';
				    	/*if(data.user.roomInfo != null && data.user.roomInfo.vdo_status == '1'){
				    		html += '            <span></span>';
						    html += '            <div class="loader-inner line-scale-pulse-out">';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '            </div>';
				    	}*/
				    html += '            <img src="'+data.user.avatar+'" />';
				    html += '        </div>';
				    html += '    </a>';
				    html += '    <h3 class="phbName">'+ data.user.nick_name +'</h3>';
				    html += '    <span class="phbTime">时长：'+ data.totalEffectTimeStr +'</span>';
				    html += '    <em class="phbCount">'+(i+1+10)+'</em>';
				    html += '</li>';
				}
				
				var zongWeek = $('#zongWeek').val();
				if(zongWeek == 'week'){
					//余下的显示
					$("#weekphbList").append(html);
					if($("#weekphbList").find("li").length >= 27){
						$(".more").remove();
						$("#weekphbList").append('<div class="daodi">亲已经到底了哦~</div>');
					}else{
						if(total < 20){
							$(".more").remove();
							$("#weekphbList").append('<div class="daodi">亲已经到底了哦~</div>');
						}
					}
				}else if(zongWeek == 'zong'){
					//余下的显示
					$("#zongphbList").append(html);
					if($("#zongphbList").find("li").length >= 27){
						$(".more").remove();
						$("#zongphbList").append('<div class="daodi">亲已经到底了哦~</div>');
					}else{
						if(total < 20){
							$(".more").remove();
							$("#zongphbList").append('<div class="daodi">亲已经到底了哦~</div>');
						}
					}
				}
        });
	},
	wanrenmi1:function(startDate, endDate, startOffset, pageSize){
		var _this = this;
        _this.requestRemoteData({'url': encodeURI(encodeURI(location.href.split('#')[0])), "type":"2", "startTime":startDate, "endTime":endDate, "startOffset":startOffset, "pageSize":pageSize, "userId":$('#userId').val(), "configId":$('#configId').val()}, function(res){
        	var user = res.user;
        	if(res.errorCode != 0){
        		return;
        	}
        	var total = res.result.length;
        	var html = '';
        	var html1 = '';
        	var html2 = '';
        	var html3 = '';
        	
        	var data1 = res.result[0];
        	var data2 = res.result[1];
        	var data3 = res.result[2];
        	
			if(total > 0 && typeof(data1.user) != "undefined"){
				html1 += '<li class="phbNo1">';
			    html1 += '    <a href="javascript:void(0)">';
                html1 += '    <section class="phbHead">';
                html1 += '        <div class="phbWrap">';
                   	/*if(data1.user.roomInfo != null && data1.user.roomInfo.vdo_status == '1'){
			    		html1 += '            <span></span>';
					    html1 += '            <div class="loader-inner line-scale-pulse-out">';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '            </div>';
			    	}*/
                html1 += '            <img src="'+data1.user.avatar+'" />';
                html1 += '        </div>';
                html1 += '    </section>';
                html1 += '    <h3 class="phbName">'+ data1.user.nick_name +'</h3>';
                html1 += '    <span class="phbTime">万人迷：'+data1.total_count+'个</span>';
                html1 += '    <em class="iconNo1"></em>';
                html1 += '	</a>';
                html1 += '</li>';
			}
			if(total > 1 && typeof(data2.user) != "undefined"){
				html2 += '<li class="phbNo2">';
			    html2 += '    <a href="javascript:void(0)" class="phbHead">';
			    html2 += '       <div class="phbWrap">';
			    	/*if(data2.user.roomInfo != null && data2.user.roomInfo.vdo_status == '1'){
			    		html2 += '<span></span>';
		                html2 += '<div class="loader-inner line-scale-pulse-out">';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '</div>';
			    	}*/
			    html2 += '            <img src="'+data2.user.avatar+'" />';
			    html2 += '        </div>';
			    html2 += '    </a>';
			    html2 += '    <h3 class="phbName">'+ data2.user.nick_name +'</h3>';
			    html2 += '    <span class="phbTime">万人迷：'+ data2.total_count +'个</span>';
			    html2 += '    <em class="iconNo2"></em>';
			    html2 += '</li>';
			}
			if(total > 2 && typeof(data3.user) != "undefined"){
				html3 += '<li class="phbNo3">';
			    html3 += '    <a href="javascript:void(0)" class="phbHead">';
			    html3 += '       <div class="phbWrap">';
			    	/*if(data3.user.roomInfo != null && data3.user.roomInfo.vdo_status == '1'){
			    		html3 += '<span></span>';
		                html3 += '<div class="loader-inner line-scale-pulse-out">';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '</div>';
			    	}*/
			    html3 += '            <img src="'+data3.user.avatar+'" />';
			    html3 += '        </div>';
			    html3 += '    </a>';
			    html3 += '    <h3 class="phbName">'+ data3.user.nick_name +'</h3>';
			    html3 += '    <span class="phbTime">万人迷：'+ data3.total_count +'个</span>';
			    html3 += '    <em class="iconNo3"></em>';
			    html3 += '</li>';
			}
			
			for (var i = 0; i < total; i++) {
				if(i < 3){
					continue;
				}
				var data = res.result[i];
				html += '<li>';
			    html += '    <a href="javascript:void(0)" class="phbHead">';
			    html += '        <div class="phbWrap">';
			    	/*if(data.user.roomInfo != null && data.user.roomInfo.vdo_status == '1'){
			    		html += '            <span></span>';
					    html += '            <div class="loader-inner line-scale-pulse-out">';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '            </div>';
			    	}*/
			    html += '            <img src="'+data.user.avatar+'" />';
			    html += '        </div>';
			    html += '    </a>';
			    html += '    <h3 class="phbName">'+ data.user.nick_name +'</h3>';
			    html += '    <span class="phbTime">万人迷：'+ data.total_count +'个</span>';
			    html += '    <em class="phbCount">'+(i+1)+'</em>';
			    html += '</li>';
			}
			var zongWeek = $('#zongWeek').val();
			if(zongWeek == 'week'){
				//前三条显示
				$("#weekPhbTopThree").find("ul").html(html2+html1+html3);
				//余下的显示
				$("#weekphbList").html(html);
				$("#weekphbList").append('<a class="more">点击查看更多</a>');
			}else if(zongWeek == 'zong'){
				//前三条显示
				$("#zongPhbTopThree").find("ul").html(html2+html1+html3);
				//余下的显示
				$("#zongphbList").html(html);
				$("#zongphbList").append('<a class="more">点击查看更多</a>');
			}
		});
	},
	wanrenmi2:function(startDate, endDate, startOffset, pageSize){
		var _this = this;
        _this.requestRemoteData({'url': encodeURI(encodeURI(location.href.split('#')[0])), "type":"2", "startTime":startDate, "endTime":endDate, "startOffset":startOffset, "pageSize":pageSize, "userId":$('#userId').val(), "configId":$('#configId').val()}, function(res){
			var total = res.result.length;
        	var html = '';
			for (var i = 0; i < total; i++) {
				var data = res.result[i];
				if(typeof(data.user)=="undefined"){
					continue;
				}
				html += '<li>';
			    html += '    <a href="javascript:void(0)" class="phbHead">';
			    html += '        <div class="phbWrap">';
			    	/*if(data.user.roomInfo != null && data.user.roomInfo.vdo_status == '1'){
			    		html += '            <span></span>';
					    html += '            <div class="loader-inner line-scale-pulse-out">';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '            </div>';
			    	}*/
			    html += '            <img src="'+data.user.avatar+'" />';
			    html += '        </div>';
			    html += '    </a>';
			    html += '    <h3 class="phbName">'+ data.user.nick_name +'</h3>';
			    html += '    <span class="phbTime">万人迷：'+ data.total_count +'个</span>';
			    html += '    <em class="phbCount">'+(i+1+10)+'</em>';
			    html += '</li>';
			}
			
			var zongWeek = $('#zongWeek').val();
			if(zongWeek == 'week'){
				//余下的显示
				$("#weekphbList").append(html);
				if($("#weekphbList").find("li").length >= 27){
					$(".more").remove();
					$("#weekphbList").append('<div class="daodi">亲已经到底了哦~</div>');
				}else{
					if(total < 20){
						$(".more").remove();
						$("#weekphbList").append('<div class="daodi">亲已经到底了哦~</div>');
					}
				}
			}else if(zongWeek == 'zong'){
				//余下的显示
				$("#zongphbList").append(html);
				if($("#zongphbList").find("li").length >= 27){
					$(".more").remove();
					$("#zongphbList").append('<div class="daodi">亲已经到底了哦~</div>');
				}else{
					if(total < 20){
						$(".more").remove();
						$("#zongphbList").append('<div class="daodi">亲已经到底了哦~</div>');
					}
				}
			}
				
		});
	},
	meiliouxiang1:function(startDate, endDate, startOffset, pageSize){
		var _this = this;
        _this.requestRemoteData({'url': encodeURI(encodeURI(location.href.split('#')[0])), "type":"3", "startTime":startDate, "endTime":endDate, "startOffset":startOffset, "pageSize":pageSize, "userId":$('#userId').val(), "configId":$('#configId').val()}, function(res){
        	var user = res.user;
        	if(res.errorCode != 0){
        		return;
        	}
        	var total = res.result.length;
        	var html = '';
        	var html1 = '';
        	var html2 = '';
        	var html3 = '';
        	
        	var data1 = res.result[0];
        	var data2 = res.result[1];
        	var data3 = res.result[2];
        	
			if(total > 0 && typeof(data1.user) != "undefined"){
				html1 += '<li class="phbNo1">';
			    html1 += '    <a href="javascript:void(0)">';
                html1 += '    <section class="phbHead">';
                html1 += '        <div class="phbWrap">';
                   	/*if(data1.user.roomInfo != null && data1.user.roomInfo.vdo_status == '1'){
			    		html1 += '            <span></span>';
					    html1 += '            <div class="loader-inner line-scale-pulse-out">';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '            </div>';
			    	}*/
                html1 += '            <img src="'+data1.user.avatar+'" />';
                html1 += '        </div>';
                html1 += '    </section>';
                html1 += '    <h3 class="phbName">'+ data1.user.nick_name +'</h3>';
                html1 += '    <span class="phbTime">红包：'+data1.total_count+'个</span>';
                html1 += '    <em class="iconNo1"></em>';
                html1 += '	</a>';
                html1 += '</li>';
			}
			if(total > 1 && typeof(data2.user) != "undefined"){
				html2 += '<li class="phbNo2">';
			    html2 += '    <a href="javascript:void(0)" class="phbHead">';
			    html2 += '       <div class="phbWrap">';
			    	/*if(data2.user.roomInfo != null && data2.user.roomInfo.vdo_status == '1'){
			    		html2 += '<span></span>';
		                html2 += '<div class="loader-inner line-scale-pulse-out">';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '</div>';
			    	}*/
			    html2 += '            <img src="'+data2.user.avatar+'" />';
			    html2 += '        </div>';
			    html2 += '    </a>';
			    html2 += '    <h3 class="phbName">'+ data2.user.nick_name +'</h3>';
			    html2 += '    <span class="phbTime">红包：'+ data2.total_count +'个</span>';
			    html2 += '    <em class="iconNo2"></em>';
			    html2 += '</li>';
			}
			if(total > 2 && typeof(data3.user) != "undefined"){
				html3 += '<li class="phbNo3">';
			    html3 += '    <a href="javascript:void(0)" class="phbHead">';
			    html3 += '       <div class="phbWrap">';
			    	/*if(data3.user.roomInfo != null && data3.user.roomInfo.vdo_status == '1'){
			    		html3 += '<span></span>';
		                html3 += '<div class="loader-inner line-scale-pulse-out">';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '</div>';
			    	}*/
			    html3 += '            <img src="'+data3.user.avatar+'" />';
			    html3 += '        </div>';
			    html3 += '    </a>';
			    html3 += '    <h3 class="phbName">'+ data3.user.nick_name +'</h3>';
			    html3 += '    <span class="phbTime">红包：'+ data3.total_count +'个</span>';
			    html3 += '    <em class="iconNo3"></em>';
			    html3 += '</li>';
			}
			
			for (var i = 0; i < total; i++) {
				if(i < 3){
					continue;
				}
				var data = res.result[i];
				html += '<li>';
			    html += '    <a href="javascript:void(0)" class="phbHead">';
			    html += '        <div class="phbWrap">';
			    	/*if(data.user.roomInfo != null && data.user.roomInfo.vdo_status == '1'){
			    		html += '            <span></span>';
					    html += '            <div class="loader-inner line-scale-pulse-out">';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '            </div>';
			    	}*/
			    html += '            <img src="'+data.user.avatar+'" />';
			    html += '        </div>';
			    html += '    </a>';
			    html += '    <h3 class="phbName">'+ data.user.nick_name +'</h3>';
			    html += '    <span class="phbTime">红包：'+ data.total_count +'个</span>';
			    html += '    <em class="phbCount">'+(i+1)+'</em>';
			    html += '</li>';
			}
			var zongWeek = $('#zongWeek').val();
			if(zongWeek == 'week'){
				//前三条显示
				$("#weekPhbTopThree").find("ul").html(html2+html1+html3);
				//余下的显示
				$("#weekphbList").html(html);
				$("#weekphbList").append('<a class="more">点击查看更多</a>');
			}else if(zongWeek == 'zong'){
				//前三条显示
				$("#zongPhbTopThree").find("ul").html(html2+html1+html3);
				//余下的显示
				$("#zongphbList").html(html);
				$("#zongphbList").append('<a class="more">点击查看更多</a>');
			}
		});
	},
	meiliouxiang2:function(startDate, endDate, startOffset, pageSize){
		var _this = this;
        _this.requestRemoteData({'url': encodeURI(encodeURI(location.href.split('#')[0])), "type":"3", "startTime":startDate, "endTime":endDate, "startOffset":startOffset, "pageSize":pageSize, "userId":$('#userId').val(), "configId":$('#configId').val()}, function(res){
			var total = res.result.length;
            	var html = '';
				for (var i = 0; i < total; i++) {
					var data = res.result[i];
					if(typeof(data.user)=="undefined"){
						continue;
					}
					html += '<li>';
				    html += '    <a href="javascript:void(0)" class="phbHead">';
				    html += '        <div class="phbWrap">';
				    	/*if(data.user.roomInfo != null && data.user.roomInfo.vdo_status == '1'){
				    		html += '            <span></span>';
						    html += '            <div class="loader-inner line-scale-pulse-out">';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '            </div>';
				    	}*/
				    html += '            <img src="'+data.user.avatar+'" />';
				    html += '        </div>';
				    html += '    </a>';
				    html += '    <h3 class="phbName">'+ data.user.nick_name +'</h3>';
				    html += '    <span class="phbTime">红包：'+ data.total_count +'个</span>';
				    html += '    <em class="phbCount">'+(i+1+10)+'</em>';
				    html += '</li>';
				}
				
				var zongWeek = $('#zongWeek').val();
				if(zongWeek == 'week'){
					//余下的显示
					$("#weekphbList").append(html);
					if($("#weekphbList").find("li").length >= 27){
						$(".more").remove();
						$("#weekphbList").append('<div class="daodi">亲已经到底了哦~</div>');
					}else{
						if(total < 20){
							$(".more").remove();
							$("#weekphbList").append('<div class="daodi">亲已经到底了哦~</div>');
						}
					}
				}else if(zongWeek == 'zong'){
					//余下的显示
					$("#zongphbList").append(html);
					if($("#zongphbList").find("li").length >= 27){
						$(".more").remove();
						$("#zongphbList").append('<div class="daodi">亲已经到底了哦~</div>');
					}else{
						if(total < 20){
							$(".more").remove();
							$("#zongphbList").append('<div class="daodi">亲已经到底了哦~</div>');
						}
					}
				}
				
		});
	},
    shenhao1:function(startDate, endDate, startOffset, pageSize){
    	var _this = this;
        _this.requestRemoteData({'url': encodeURI(encodeURI(location.href.split('#')[0])), "type":"4", "startTime":startDate, "endTime":endDate, "startOffset":startOffset, "pageSize":pageSize, "userId":$('#userId').val(), "configId":$('#configId').val()}, function(res){
        	var user = res.user;
        	if(res.errorCode != 0){
        		return;
        	}
        	var total = res.result.length;
        	var html = '';
        	var html1 = '';
        	var html2 = '';
        	var html3 = '';
        	
        	var data1 = res.result[0];
        	var data2 = res.result[1];
        	var data3 = res.result[2];
        	
			if(total > 0 && typeof(data1.user) != "undefined"){
				html1 += '<li class="phbNo1">';
			    html1 += '    <a href="javascript:void(0)">';
                html1 += '    <section class="phbHead">';
                html1 += '        <div class="phbWrap">';
                   	/*if(data1.user.roomInfo != null && data1.user.roomInfo.vdo_status == '1'){
			    		html1 += '            <span></span>';
					    html1 += '            <div class="loader-inner line-scale-pulse-out">';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '                <div></div>';
					    html1 += '            </div>';
			    	}*/
                html1 += '            <img src="'+data1.user.avatar+'" />';
                html1 += '        </div>';
                html1 += '    </section>';
                html1 += '    <h3 class="phbName">'+ data1.user.nick_name +'</h3>';
                html1 += '    <span class="phbTime">红包：'+data1.total_count+'个</span>';
                html1 += '    <em class="iconNo1"></em>';
                html1 += '	</a>';
                html1 += '</li>';
			}
			if(total > 1 && typeof(data2.user) != "undefined"){
				html2 += '<li class="phbNo2">';
			    html2 += '    <a href="javascript:void(0)" class="phbHead">';
			    html2 += '       <div class="phbWrap">';
			    	/*if(data2.user.roomInfo != null && data2.user.roomInfo.vdo_status == '1'){
			    		html2 += '<span></span>';
		                html2 += '<div class="loader-inner line-scale-pulse-out">';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '    <div></div>';
		                html2 += '</div>';
			    	}*/
			    html2 += '            <img src="'+data2.user.avatar+'" />';
			    html2 += '        </div>';
			    html2 += '    </a>';
			    html2 += '    <h3 class="phbName">'+ data2.user.nick_name +'</h3>';
			    html2 += '    <span class="phbTime">红包：'+ data2.total_count +'个</span>';
			    html2 += '    <em class="iconNo2"></em>';
			    html2 += '</li>';
			}
			if(total > 2 && typeof(data3.user) != "undefined"){
				html3 += '<li class="phbNo3">';
			    html3 += '    <a href="javascript:void(0)" class="phbHead">';
			    html3 += '       <div class="phbWrap">';
			    	/*if(data3.user.roomInfo != null && data3.user.roomInfo.vdo_status == '1'){
			    		html3 += '<span></span>';
		                html3 += '<div class="loader-inner line-scale-pulse-out">';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '    <div></div>';
		                html3 += '</div>';
			    	}*/
			    html3 += '            <img src="'+data3.user.avatar+'" />';
			    html3 += '        </div>';
			    html3 += '    </a>';
			    html3 += '    <h3 class="phbName">'+ data3.user.nick_name +'</h3>';
			    html3 += '    <span class="phbTime">红包：'+ data3.total_count +'个</span>';
			    html3 += '    <em class="iconNo3"></em>';
			    html3 += '</li>';
			}
			
			for (var i = 0; i < total; i++) {
				if(i < 3){
					continue;
				}
				var data = res.result[i];
				html += '<li>';
			    html += '    <a href="javascript:void(0)" class="phbHead">';
			    html += '        <div class="phbWrap">';
			    	/*if(data.user.roomInfo != null && data.user.roomInfo.vdo_status == '1'){
			    		html += '            <span></span>';
					    html += '            <div class="loader-inner line-scale-pulse-out">';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '                <div></div>';
					    html += '            </div>';
			    	}*/
			    html += '            <img src="'+data.user.avatar+'" />';
			    html += '        </div>';
			    html += '    </a>';
			    html += '    <h3 class="phbName">'+ data.user.nick_name +'</h3>';
			    html += '    <span class="phbTime">红包：'+ data.total_count +'个</span>';
			    html += '    <em class="phbCount">'+(i+1)+'</em>';
			    html += '</li>';
			}
			var zongWeek = $('#zongWeek').val();
			if(zongWeek == 'week'){
				//前三条显示
				$("#weekPhbTopThree").find("ul").html(html2+html1+html3);
				//余下的显示
				$("#weekphbList").html(html);
				$("#weekphbList").append('<a class="more">点击查看更多</a>');
			}else if(zongWeek == 'zong'){
				//前三条显示
				$("#zongPhbTopThree").find("ul").html(html2+html1+html3);
				//余下的显示
				$("#zongphbList").html(html);
				$("#zongphbList").append('<a class="more">点击查看更多</a>');
			}
		});
	},
	shenhao2:function(startDate, endDate, startOffset, pageSize){
		var _this = this;
        _this.requestRemoteData({'url': encodeURI(encodeURI(location.href.split('#')[0])), "type":"4", "startTime":startDate, "endTime":endDate, "startOffset":startOffset, "pageSize":pageSize, "userId":$('#userId').val(), "configId":$('#configId').val()}, function(res){
			var total = res.result.length;
            	var html = '';
				for (var i = 0; i < total; i++) {
					var data = res.result[i];
					if(typeof(data.user)=="undefined"){
						continue;
					}
					html += '<li>';
				    html += '    <a href="javascript:void(0)" class="phbHead">';
				    html += '        <div class="phbWrap">';
				    	/*if(data.user.roomInfo != null && data.user.roomInfo.vdo_status == '1'){
				    		html += '            <span></span>';
						    html += '            <div class="loader-inner line-scale-pulse-out">';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '                <div></div>';
						    html += '            </div>';
				    	}*/
				    html += '            <img src="'+data.user.avatar+'" />';
				    html += '        </div>';
				    html += '    </a>';
				    html += '    <h3 class="phbName">'+ data.user.nick_name +'</h3>';
				    html += '    <span class="phbTime">红包：'+ data.total_count +'个</span>';
				    html += '    <em class="phbCount">'+(i+1+10)+'</em>';
				    html += '</li>';
				}
				
				var zongWeek = $('#zongWeek').val();
				if(zongWeek == 'week'){
					//余下的显示
					$("#weekphbList").append(html);
					if($("#weekphbList").find("li").length >= 27){
						$(".more").remove();
						$("#weekphbList").append('<div class="daodi">亲已经到底了哦~</div>');
					}else{
						if(total < 20){
							$(".more").remove();
							$("#weekphbList").append('<div class="daodi">亲已经到底了哦~</div>');
						}
					}
				}else if(zongWeek == 'zong'){
					//余下的显示
					$("#zongphbList").append(html);
					if($("#zongphbList").find("li").length >= 27){
						$(".more").remove();
						$("#zongphbList").append('<div class="daodi">亲已经到底了哦~</div>');
					}else{
						if(total < 20){
							$(".more").remove();
							$("#zongphbList").append('<div class="daodi">亲已经到底了哦~</div>');
						}
					}
				}
				
		});
	},
	tongji:function(){
		var _this = this;
		var urlParameters = _this.GetRequest();
		var user_id = urlParameters['user_id']||'';
		var room_id = urlParameters['room_id']||'';
		var share_config_id = urlParameters['share_config_id']||'';
		_this.requestRemoteData1(this.baseUrl+"/ad_theme_count", {"catalog":"shareDownloadNum", "user_id":user_id, "room_id":room_id, "share_config_id":share_config_id}, function(res){
			console.log(JSON.stringify(res));
		});
	},
	GetRequest:function() { 
		var url = location.search; //获取url中"?"符后的字串 
		var theRequest = new Object();
		if(url.indexOf("?") != -1) {
			var str = url.substr(1);
			strs = str.split("&");
			for(var i = 0; i < strs.length; i++) {
				theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
			}
		}
		return theRequest;
	}, 
	clearList:function(){
		$("#weekPhbTopThree, #zongPhbTopThree").find("ul").html('');
    	$("#weekphbList, #zongphbList").html('');
	},
	requestRemoteData:function(data, callback){
		console.log(JSON.stringify(data));
		var begin = (new Date()).getTime();
		$.ajax({
            url: this.baseUrl+"/ShiHouStarsAjaxApiServlet",
            type: 'GET',
            async: true,
            dataType: "jsonp",
            timeout:10000,
            jsonp: "callback", 
			jsonpCallback: "success_jsonpCallback", 
            data: data,
            success: callback,
            beforeSend:function(){
				$(".loading,.zgz").show();
			},
			complete:function(){
				console.log(" load complete."+ ((new Date()).getTime()-begin));
            	$(".loading,.zgz").hide();
            },
            error: function (data) {
            	var status = data.status;
            	if(status != 200){
	            	$(".loading").hide();
	            	$(".shibai,.zgz").show();
	            	setTimeout('$(".shibai").hide();', 1000);	
            	}
            }
        });
	},
	requestRemoteData1:function(url, data, callback){
		console.log(JSON.stringify(data));
		var begin = (new Date()).getTime();
		$.ajax({
            url: url,
            type: 'GET',
            async: true,
            data: data,
            success: callback,
            error: function (data) {
            }
        });
	}
}
